package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.SearchStat;
import com.java.control.search.SupplierSearchCond;
import com.java.entity.Supplier;
import com.java.service.SupplierService;

/**
 * 供应商管理
 * @author wqf
 * @version  Nov 24, 2011 12:00:53 PM
 */
public class SupplierListController extends AbstractAdminCommandController {

	public SupplierListController(){
		this.setCommandClass(SupplierSearchCond.class);
	}	

	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		SupplierSearchCond searchCond = (SupplierSearchCond)command;
		
		ModelAndView mav=new ModelAndView(this.view);
		searchCond.setPageSize(200L);
		SearchStat searchStat = this.supplierService.getSearchStat(Supplier.class, searchCond);
		List<Supplier> List = this.supplierService.search(Supplier.class,searchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);
		mav.addObject("supplierList", List);		
				
		return mav;
		
	}
		
	private String view;
	private SupplierService supplierService;
	
	public void setSupplierService(SupplierService supplierService) {
		this.supplierService = supplierService;
	}

	public void setView(String view) {
		this.view = view;
	}

}
